package pzl.com.transitionsframework;

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.transition.Scene;
import android.transition.TransitionInflater;
import android.transition.TransitionManager;
import android.view.View;
import android.widget.LinearLayout;

public class Activity1 extends AppCompatActivity {
    private Scene scene_1a, scene_2a;
    private TransitionManager transitionManager;
    private LinearLayout baseLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_1);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        baseLayout = (LinearLayout) findViewById(R.id.baseLayout);

        scene_1a = new Scene(baseLayout, findViewById(R.id.initLayout));
        scene_2a = Scene.getSceneForLayout(baseLayout, R.layout.scene_2a, this);
        TransitionInflater inflater = TransitionInflater.from(this);
        transitionManager = inflater.inflateTransitionManager(R.transition.transition_manager,
                baseLayout);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }


    public void click(View v) {
        switch (v.getId()) {
            case R.id.btn01:
                transitionManager.go(scene_2a);
                break;
        }
    }

}
